<include file="Public:header" />
<div id="page-wrapper">
	<div class="row">
		<div class="col-lg-12">
			<h1 class="page-header" style="margin-top: 0px;"></h1>
		</div>
		<!-- /.col-lg-12 -->
	</div>
	<div class="row">
		<div class="col-lg-12">
			<div class="panel panel-default">
				<div class="panel-heading">
					<b>店铺管理</b>
				</div>
				<!-- /.panel-heading -->
				<div class="panel-body">
					<div class="dataTable_wrapper">
						<div id="dataTables-example_wrapper"
							class="dataTables_wrapper form-inline dt-bootstrap no-footer">
							<div class="row">


								<div class="col-sm-4">
									<form action="__URL__/shop" method="get">
										<div class="dataTables_filter" style="float: right;">
											<label>店铺名称: <input type="search" name="name"
												value="<{$name}>" class="form-control input-sm"
												placeholder="">
											</label>
											<button class='btn btn-primary'>查询</button>

										</div>
									</form>
								</div>
							</div>
							<div class="row">
								<div class="col-sm-12">
									<table id="yao_table"
										class="table table-striped table-bordered table-hover dataTable no-footer">
										<thead>
											<tr role="row">
												<!-- <th style="width: 30px;text-align: center;"  >
                                                <input type="checkbox" name="checkedAll" id="checkedAll"/>
                                            </th> -->
												<th tabindex="0" style="text-align: center;">所属城市</th>
												<th style="text-align: center;">广场名称</th>
												<th style="text-align: center;">楼层名称</th>
												<th style="text-align: center;">店铺名称</th>
												<th tabindex="0" style="text-align: center;">巡检设备数</th>
												<th tabindex="0" style="text-align: center;">iBeacon总数</th>

											</tr>
										</thead>
										<tbody>
											<volist name="r" id='vo'>
											<tr class="gradeA odd" role="row">
												<td><{$vo.location_name}></td>
												<td><{$vo.campus_name}></td>
												<td><{$vo.floor_name}></td>
												<td><{$vo.shop_name}></td>
												<td><{$vo.count_bt}></td>
												<td><{$vo.count_ib}></td>
											</tr>
											</volist>

										</tbody>
									</table>
								</div>
							</div>



							<div class="row">
								<div class="col-sm-12">
									<div class='pages'><{$show}></div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!-- /.panel-body -->
			</div>
			<!-- /.panel -->
		</div>
		<!-- /.col-lg-12 -->
	</div>

</div>

<!-- 此节点内部的内容会在弹出框内显示,默认隐藏此节点-->
<div id="content" class="hide">
	<form class="form-horizontal">
		<div class="row">
			<div class="control-group span8">
				<label class="control-label" style="padding-top: 0px;">登陆名：</label>
				<div class="controls">
					<input type="text" id="username" name="username"
						class="input-normal control-text" style="height: 30px;">
				</div>
			</div>
			<!-- <div class="control-group span8">
            <label class="control-label" style=" padding-top: 0px;">登陆密码：</label>
            <div class="controls">
              <input type="text"  name="password" class="input-normal control-text" style="height:30px;">
            </div>
          </div> -->
			<div class="control-group span8">
				<label class="control-label" style="padding-top: 0px;">登陆密码：</label>
				<div class="controls">
					<input type="text" name='passwd' class="input-normal control-text"
						style="height: 30px;">
				</div>
			</div>
			<!--
           <div class="control-group span8">
            <label class="control-label" style=" padding-top: 0px;">所属部门：</label>
            <div class="controls">
              <select id="sec_tion" class="input-normal"> 
                    <volist name="section" id="v">
                        <option value="<{$v.id}>"><{$v.sec_name}></option>
                    </volist>
              </select>
            </div>
          </div> -->
		</div>
	</form>
</div>

<script src="public/js/jquery-1.8.3.min.js" type="text/javascript">
	
</script>
<script type="text/javascript">
	$(document).ready(function() {

		$("#checkedAll").click(function() {
			if ($(this).prop('checked')) { // 全选 
				$("input[name='checkbox_name']").each(function() {
					$(this).prop('checked', true);
				});
			} else { // 取消全选 
				$("input[name='checkbox_name']").each(function() {
					$(this).prop('checked', false);
					;
				});
			}
		});

	});

	// function link(){
	//      var checkedList = new Array();
	//      $("input[name='checkbox_name']:checked").each(function(){
	//          checkedList.push($(this).val());
	//      });
	//      alert(checkedList);
	//    }
</script>
<script src="http://g.alicdn.com/bui/bui/1.1.16/bui.js"></script>
<!-- 删除用户 -->
<script type="text/javascript">
	//消息消失
	function dispoint(messge) {
		BUI.Message.Show({
			msg : messge,
			icon : 'success',
			buttons : [],
			autoHide : true,
			autoHideDelay : 1000

		});
	}

	function show(hidden) {
		BUI.Message.Confirm('确认要删除？', function() {
			setTimeout(function() {
				$.ajax({
					type : 'get',
					url : '__URL__/delCommager?id=' + hidden,
					success : function(msg) {
						dispoint("删除成功！");
						location.reload();
					}
				});

				//BUI.Message.Alert('这只是简单的错误信息','error');
			});

		}, 'question');
	}

	$('.yaodel_btnShow').on('click', function() {
		var hidden = $(this).parent().prev().find("input").val();
		show(hidden);
	});
</script>
<!-- 编辑和添加用户js -->
<script type="text/javascript">
	var Overlay = BUI.Overlay
	$('.yaoedit_btnShow')
			.on(
					'click',
					function() {
						var id = $(this).parent().prev().find("input").val();
						var username = $.trim($(this).parent().prev().prev()
								.prev().html());
						var login_name = $.trim($(this).parent().prev().prev()
								.html());
						//var sec_id = $(this).parent().prev().prev().find("input").val();
						//var sec_obj = $("#sec_tion");
						//jsSelectIsExitItem(sec_obj, sec_id);//自定义函数

						//$("#section").find("option[value=sec_id]").attr("selected",true);

						$("input[name='username']").val(username);
						$("input[name='passwd']").val(login_name);
						var dialog = new Overlay.Dialog(
								{
									title : '编辑普通管理员',
									width : 350,
									height : 180,
									closeAction : 'destroy', //每次关闭dialog释放
									//配置DOM容器的编号
									contentId : 'content',
									buttons : [
											{
												text : '保存',
												elCls : 'button button-primary',
												handler : function() {
													var username = $.trim($(
															"#username").val());
													var passwd = $
															.trim($(
																	"input[name='passwd']")
																	.val());
													var sec_id = $("#sec_tion")
															.val();
													var login_name = $
															.trim($(
																	"input[name='login_name']")
																	.val());

													$
															.ajax({
																type : 'post',
																url : '__URL__/editCommager',
																data : {
																	'username' : username,
																	'passwd' : passwd,
																	'sec_id' : sec_id,
																	'login_name' : login_name,
																	'id' : id
																},
																dataType : 'json',
																success : function(
																		msg) {
																	// alert(msg);
																	dispoint("保存成功！");
																	dialog
																			.close();
																	location
																			.reload();
																}
															});
												}
											}, {
												text : '取消',
												elCls : 'button',
												handler : function() {
													this.close();
												}
											} ]
								});
						dialog.show();
					});

	function link() {
		$("#username").val('');
		$("input[name='login_name']").val('');
		var Overlay = BUI.Overlay
		var dialog = new Overlay.Dialog({
			title : '添加普通管理员',
			width : 350,
			height : 180,
			closeAction : 'destroy', //每次关闭dialog释放
			//配置DOM容器的编号
			contentId : 'content',
			success : function() {
				var username = $.trim($("#username").val());
				var login_name = $.trim($("input[name='login_name']").val());

				var sec_id = $("#sec_tion").val();
				var passwd = $.trim($("input[name='passwd']").val());

				$.ajax({
					type : 'post',
					url : '__URL__/addCommager',
					data : {
						'username' : username,
						'passwd' : passwd,
						"login_name" : login_name,
						"sec_id" : sec_id
					},
					dataType : 'json',
					success : function(msg) {
						dispoint("添加成功！");
						dialog.close();
						location.reload();
					}
				});
			}
		});
		dialog.show();
	}

	// 1.判断select选项中 是否存在Value="paraValue"的Item  
	function jsSelectIsExitItem(objSelect, objItemValue) {
		for (var i = 0; i < objSelect[0].length; i++) {
			if (objSelect[0][i].value == objItemValue) {
				objSelect[0][i].selected = true;
				break;
			}
		}

	}
</script>

<include file="Public:footer" />
